package com.example.interpreter2;

public class LoopCommandNode implements Node{

    private Node node;
    private int loopNum;

    @Override
    public void interpret(Context context) {
        context.skipToken("LOOP");
        this.loopNum = context.currentNumber();
        context.nextToken();
        ExpressionNode node = new ExpressionNode();
        node.interpret(context);
        this.node = node;
    }

    @Override
    public void execute() {
        for (int i = 0; i < this.loopNum; i++) {
            this.node.execute();
        }
    }
    
}
